<template>
	<view class="content">
		<!-- <web-view v-if="isIos"   :src="'file://' + path"></web-view> -->
		<!-- <web-view  :src="path"></web-view> -->
		<NavBar title="下載" :autoBack="false" id="nav">
			
		</NavBar>
		<view class="center main">
			<view class="flex dirCloumn" v-if="path">
				<view class="text text-center text-16 text-bold" v-if="title">{{ title }}</view>
				<u-button class="download-btn mt-30" shape="square" type="primary" @click="downFile()">下载文件</u-button>
			</view>
			<u-empty v-else text="下載地址錯誤" mode="data"></u-empty>
		</view>
		
		
	</view>
</template>

<script>
	import NavBar from "@/component/NavBar"
	import { mapState, mapMutations } from "vuex";
	import {downLoadFile } from "@/utils/util/uploadFun.js"
	import {isWxBrowser, isIos } from "@/utils/util/index.js"
	export default {
		components:{
			NavBar,
		},
		data() {
			return {
				path:"",
				title:"",
				isIos:null,
				isWx:null,
			}
		},
		
		onShow() {
			
			const systemInfo = uni.getSystemInfoSync()
			this.isIos=isIos()
			this.isWx=isWxBrowser()
			const { path,title } = this.$Route.query
			if(!path){
				this.$Toast("數據錯誤")
				setTimeout(()=>{
					this.toPage("Main")
				},1200)
			}else{
				this.$nextTick(()=>{
					this.path=path
					this.title=title
				})
				
			}
		},
		onLoad(){
			
			
			
		},
		
		methods: {
			...mapMutations(['changeUserIdent','changeUserName']),
			downFile(){
				console.log(this.path,this.title)
				if(isWxBrowser()){
					uni.showModal({
						title: '提示',
						content: '请点击右上角，在浏览器打开页面下载。',
						showCancel: false
					})
					return false;
				}else{
					 downLoadFile(this.path)
				}
			},
			toPage(name,params={}){
				this.$navi({
				    route:{
				        name,
						params
				    },
				})
			}
		}
	}
</script>

<style lang="scss">
	.content{
		height: 100vh;
	}
	.main{
		height: calc(100vh - 88rpx);
	}
	.share{
		position: relative;
		z-index: 2;
		padding: 10rpx 30rpx;
		border: 2rpx solid #e6e6e6;
		border-radius: 8rpx;
	}
</style>